import logging
from os import sys

from django.conf.urls.defaults import *
from django.core.urlresolvers import RegexURLPattern

from settings import INSTALLED_APPS 
import views

# The parameters that will be passed to patterns()
p = ['',
     (r'^login/', 'djips_common.views.login'),
     (r'^logout/', 'djips_common.views.logout'),
     (r'^$', 'djips_common.views.index_redirect')]

# We check in every installed app if it contains an 'djips_admin' module
for app in INSTALLED_APPS:
    try:
	exec "from %s import djips_admin" % app
    except:
	logging.warning("%s is not a djips module" % app)
	continue

    # We create the couple (r'package', include(package.djips_admin))
    url = (r'^%s/' % app, include(app + '.djips_admin'))
    p.append(url)

urlpatterns = patterns(*p)
